package com.vegetable.modules.entity.baseData;

import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.vegetable.common.base.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat;

import java.math.BigDecimal;
import java.util.Date;

/**
 * <p>
 * 通讯录（农户,客商,代办,班组）
 * </p>
 *
 * @author wangruijie
 * @since 2024-03-07
 */
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="AddressBook对象", description="通讯录（农户,客商,代办,班组）")
public class AddressBook extends BaseEntity {

    @ApiModelProperty(value = "人员类型：0农户，1客商，2代办，3班组")
    private Integer staffType;

    @TableField(exist = false)
    @ApiModelProperty(value = "人员类型：0农户，1客商，2代办，3班组")
    private String staffTypeName;

    @ApiModelProperty(value = "初始欠款")
    private BigDecimal initArrears;

    @ApiModelProperty(value = "市场")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long marketId;

    @ApiModelProperty(value = "市场名称")
    private String marketName;

    @ApiModelProperty(value = "市场别名")
    private String alias;

    @ApiModelProperty(value = "应收金额")
    private BigDecimal arrears;

    @ApiModelProperty(value = "手机号")
    private String mobile;

    @ApiModelProperty(value = "销售模式:0代销，1直销")
    private Integer mode;

    @ApiModelProperty(value = "客商名称")
    private String noteName;

    @ApiModelProperty(value = "业务员ID，关联sys_user表")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long salesmanId;

    @ApiModelProperty(value = "业务员名称（冗余字段）")
    private String salesman;

    @ApiModelProperty(value = "商铺")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long shopId;

    @ApiModelProperty(value = "删除标识0未删除，1删除")
    private Integer isDel;

    @ApiModelProperty(value = "创建者ID")
    private Long createUserId;

    @ApiModelProperty(value = "创建时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    public String getStaffTypeName(){
        String res;
            switch (staffType){
               case  0:
                   res ="农户";
                   break;
               case  1:
                   res ="客商";
                   break;
               case  2:
                   res ="代办";
                   break;
               case  3:
                   res ="班组";
                   break;
                default:
                    res = "";
            }
        return res;
    }
}